<?php

namespace app\common\model;

use think\Model;
use think\Db;

/**
 * 会员积分日志模型
 */
class ScoreLog extends Model
{

    // 表名
    protected $name = 'user_score_log';
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = '';
    // 追加属性
    protected $append = [
    ];

    //获取会员积分明细
    public static function get_score_log($user_id, $type)
    {
        $where = [];
        if ($type == 1) {
            $where = ['score' => ['>', 0]];
        } else if ($type == '-1') {
            $where = ['score'=>['<', 0]];
        }
        return ScoreLog::where(['user_id'=>$user_id])->where($where)->paginate();
    }
}
